package main

import (
	"fmt"
	"golang-learning/src/yayako.cn/day15/tcp-sticky-bag/protocol"
	"net"
)

func main() {
	conn, err := net.Dial("tcp", "127.0.0.1:1818")
	if err != nil {
		fmt.Println("dial failed, err:", err)
		return
	}
	defer conn.Close()
	for i := 0; i < 20; i++ {
		msg := "hello world"
		//conn.Write([]byte(msg))
		bytes, err := protocol.Encode(msg)
		if err != nil {
			fmt.Println("encode failed, err:", err)
			return
		}
		conn.Write(bytes)
	}
}
